<?php
/** $Id: default_form.php 11917 2009-05-29 19:37:05Z ian $ */
	defined( '_JEXEC' ) or die( 'Restricted access' );
	$input_image = JText::_( 'Filer skal være JPG, GIF eller PNG' );
	$input_name = JText::_( 'Skriv venligst en overskrift på din opgave' );
	$input_subject = JText::_( 'Indtast venligst dit telefon' );
	$input_text = JText::_( 'Beskriv venligst din maleropgave' );
	$input_email = JText::_( 'Indtast venligst dit email' );
	$input_pris = JText::_( 'Udfyld venligst rubrikken Jeg mener, at opgaven ca. vil koste' );
	$input_datepicker = JText::_( 'Udfyld venligst rubrikken Arbejdet ønskes afsluttet' );
	$session = JFactory::getSession();
	$app = JFactory::getApplication();
	$template = JURI::base() . 'templates/' . $app->getTemplate();
	//, mindre end 1 MB
	$popup =  JRequest::getVar( 'popup','','get' );  
	$receivedemail = "";
	 if($popup==1) {
		  $receivedemail = JRequest::getVar( 'receivedemail','','get' );
		 ?>
         <script type="text/javascript">
		 $(document).ready(function() {
  			 $("#job_title").val("");
			 $("#job_description").val("");			 
       		 $('#msg_thanks').click();		
		});	  
		 </script> 	  
         <?php
	 }
?>
<input style="display:none" class="button send-btn thickbox flr" id="msg_thanks" alt="#TB_inline?height=220&width=490&inlineId=opretOpgaverConfirm" type="button" value="Godkend" />
<div id="opretOpgaverConfirm" class="content-inner w400" style="display:none;">
    <h2 class="blue-txt">Din maleropgave er nu oprettet</h2>
    <div class="content-view">
        
        <p>Der er sendt en e-mail til <?php echo $receivedemail ;?> med en kopi af din oprettede maleropgave samt information om det videre forløb.</p>
        <p>Har du spørgsmål, er du velkommen til at kontakte os pr. telefon eller e-mail.</p>
    </div>
</div>
<script type="text/javascript">
	$(document).ready(function() {
		//$.updnWatermark.attachAll();		
		$('.prtext, .file').focus(function() {
			var value=$(this).val();
			$(this).attr("value","");
		});
		$('.prtext, .file').blur(function() {
			if($(this).val()=="") {
				$(this).val(value);
			}
		});
	});

function button_submit(){}
		
$(document).ready(function($) {
		$(".ui-datepicker-trigger").attr("alt","<?php $info = getArticle(13);  echo strip_tags($info->introtext); ?>");				   
	  /*					   
	   $("#submitbtn").click(function() {
			  if(jQuery("#opretOpgavebeskrivelseForm").valid())
			  {
	  			   alert('valit');				   
			  }
			  
		});
	  */ 
	   $.validator.addMethod('postalcode', function (value) { 
		if(value=='') return true;	
		if(value<1000) return false;	
		if(value>=3800 && value <=3999) return false;
		
		return /^\d{4}$/.test(value); 
	   }, '');
	   
	   
	   $.validator.addMethod('datedefault', function(value) {
			if(value=='dd-mm-åååå') return false;
			return /^\d{2}-\d{2}-\d{4}$/.test(value); 
		});
		$.validator.addMethod('filesize1', function(value, element, param) {
			// param = size (en bytes) 
			// element = element to validate (<input>)
			// value = value of the element (file name)
			//return this.optional(element) || (element.files[0].size <= param) 
			return this.optional(element) || ($('#file01')[0].files[0].size <= param)  
		});
		$.validator.addMethod('filesize2', function(value, element, param) {
			// param = size (en bytes) 
			// element = element to validate (<input>)
			// value = value of the element (file name)			
			//return this.optional(element) || (element.files[0].size <= param) 
			return this.optional(element) || ($('#file02')[0].files[0].size <= param)  
		});
		$.validator.addMethod('filesize3', function(value, element, param) {
			// param = size (en bytes) 
			// element = element to validate (<input>)
			// value = value of the element (file name)
			//return this.optional(element) || (element.files[0].size <= param) 
			return this.optional(element) || ($('#file03')[0].files[0].size <= param)  
		});
		$.validator.addMethod("valueNotEquals", function(value, element, arg){
		  return arg != value;
		 }, "");

		$("#opretOpgavebeskrivelseForm").validate(
			{
				errorPlacement: function(error, element) {			
			},
			invalidHandler: function(form, validator) {
			  var errors = validator.numberOfInvalids();
			if (errors) {
                //$('#alert').html(validator['errorList'][0]['message']);
				$('#msgbox').html(validator['errorList'][0]['message']);
    			$('.btnhidden').click();
            	$('#f_focus').html(validator['errorList'][0]['element'].name);
				validator['errorList'][0]['element'].focus();
				$('#TB_overlay').attr("onclick","close_popup();");
				$('#TB_closeWindowButton').attr("onclick","close_popup();");
				var erro_len = validator['errorList'].length;
				//alert(errors);
				
				$("#opretOpgavebeskrivelseForm input").removeClass("border_red");
				$("#opretOpgavebeskrivelseForm textarea").removeClass("border_red");
				for($i=0;$i<errors;$i++) {
					$('#'+validator['errorList'][$i]['element'].name).addClass("border_red");
				}
				
				
			  } else {
			  }
			},
			rules: {
                job_title : "required",
				job_description : "required",
				file01: { required: false, accept: "png|jpg|jpeg|gif"},
				file02: { required: false, accept: "png|jpg|jpeg|gif"},
				file03: { required: false, accept: "png|jpg|jpeg|gif"},
				datepicker : {required:true,datedefault:true},
				catid : { valueNotEquals: "0" }

				
			},
			messages: {
                job_title: "<?php echo $input_name; ?>",
				job_description: "<?php echo $input_text; ?>",
				file01: "<?php echo $input_image; ?>",
				file02: "<?php echo $input_image; ?>",
				file03: "<?php echo $input_image; ?>",
				datepicker: "<?php echo $input_datepicker; ?>",
				catid: "<?php echo $input_pris; ?>"
			}/*,
      		submitHandler: function() { 
			 	alert(jQuery("#opretOpgavebeskrivelseForm").serialize()); 
			}*/
		});
        close_popup=function(){		
		
    		var fel=$('#f_focus').html();            
    		$('#' + fel ).focus();			
      };
      reset_form=function(){
            document.forms[0].reset()
      };
      
	});
</script>
<input class="btnhidden thickbox flr" alt="#TB_inline?height=125&width=260&inlineId=tilmeldConfirm" type="hidden" value="Godkend" />
<div id="tilmeldConfirm" style="display:none;">
	<div class="content-view">
 	<span id="f_focus" style="display:none;"></span>
    <p class="message" id="msgbox"></p>
    </div>
</div> 

<div class="inner clearfix">
                        <!-- Tilmeld Malerfirma Form-->
                        <?php $info = getArticle(21);
							  $images = json_decode($info->images);
						?>
                        <div class="content-decoration w975 h638 bor-std" style=" <?php if (is_file($images->image_intro)) {echo "background: url('".$images->image_intro."') no-repeat scroll right bottom #FFFFFF;";} else {echo "background: url('templates/3dmaler/img/main-img-bg.jpg') no-repeat scroll right bottom #FFFFFF;";} ;?>  ">
                        	<div class="content-inner">
                                <div class="content-view w580">
                                	<script type="text/javascript">
										$(function(){
											$("input[type=file]").filestyle({ 
												 image: "<?php echo JURI::root();?>templates/3dmaler/img/browse_file_btn.png",
												 imageheight : 29,
												 imagewidth : 72,
												 width : 245
											 });
			
										});
										
									</script>
                                    <h2 class="blue-txt">Opret
maleropgave:</h2>
                                    
                                    <form action="<?php echo JRoute::_( 'index.php' );?>" method="post" class="tilmeld-form" id="opretOpgavebeskrivelseForm" enctype="multipart/form-data">
                                        <fieldset>
                                            <div class="input-set-ctn">
                                            	<p class="input-set">
                                                	<label>Overskrift på din opgave<span>*</span></label>
                                                	<input class="input-txt" type="text" name="job_title" id="job_title" value="" />
                                                    <?php $info = getArticle(7); ?>
                                                    <span class="info-icon" title="<?php echo $info->introtext;?>"></span>
                                                </p>
                                                <p class="input-set">
                                                	<label>Beskriv venligst din maleropgave<span>*</span></label>
                                                	<textarea name="job_description" id="job_description" cols="15" rows="20"></textarea>
                                                    <?php $info = getArticle(8); ?>
                                                    <span class="info-icon" title="<?php echo $info->introtext;?>"></span>
                                                </p>
                                                <label>Her kan du uploade<br/> eventuelle billeder til<br/> malerfirmaerne</label>
                                                <div class="input-set fll">
                                                    <p class="file-input-set">
                                                        <input id="file01"  name="file01" class="input-txt file" type="file" value="Der er ikke valgt nogen fil" size="40" />
                                                        
                                                        <?php $info = getArticle(9); ?>
                                                        <span class="info-icon" title="<?php echo $info->introtext;?>"></span>
                                                    </p>
                                                    <p class="file-input-set">
                                                        <input id="file02" name="file02"  class="input-txt file" type="file" title="Der er ikke valgt nogen fil" size="40" />
                                                    </p>
                                                    <p class="file-input-set">
                                                        <input id="file03" name="file03"  class="input-txt file" type="file" title="Der er ikke valgt nogen fil" size="40" />
                                                    </p>
                                                </div>
                                                <p class="input-set">
                                                	<label>Arbejdet ønskes påbegyndt<br/>hurtigst muligt?</label>
                                                	<label class="check-box"><input class="check-box" type="checkbox"  name="job_soon" id="job_soon" /> Ja</label>
                                                </p>
                                                <p class="input-set  mart15">
                                                	<label>Arbejdet ønskes afsluttet<span>*</span></label>
                                                	<input name="datepicker" value="<?php echo "dd-mm-åååå";?>" id="datepicker" class="input-txt" value="" type="text" />
                                                </p>
                                                <p class="input-set">
                                                	<label>Jeg mener, at opgaven<br/>ca. vil koste<span>*</span></label>
                                                    
                                                    <?php echo $this->pris_html; ?>
                                                    <?php $info = getArticle(10); ?>
                                                    <span class="info-icon" title="<?php echo $info->introtext;?>"></span>
                                                </p>
                                                
                                            </div>
                                            
                                            <div style="padding-right: 80px;" class="form-submit padt15">
                                                <input class="button reset-btn flr" type="reset" value="Nulstil" />
                                                 <input class="button send-btn flr" onclick="$('#opretOpgavebeskrivelseForm').submit();"  type="button" value="Videre" />
                                               
                                                <input type="hidden" name="option" value="com_jobs" />
                                                <input type="hidden" name="task" value="job_step_first" />
                                                <?php echo JHtml::_( 'form.token' ); ?>
                                                
                                            </div>	
                                        </fieldset>
                                    </form>
                                </div>
                        	</div>
                        </div>
                        <!-- /Tilmeld Malerfirma Form-->
                        
                    </div>                   